package com.zd.springcloud.tccaction;

import com.zd.springcloud.domain.Order;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface OrderAction {

    /**
     * 添加订单 try阶段
     */

    @TwoPhaseBusinessAction(useTCCFence = true,name = "addOrder",commitMethod = "commit",rollbackMethod = "rollback")
    void addOrder(BusinessActionContext businessActionContext,@BusinessActionContextParameter("order") Order order);

    /**
     *
     *  commit 阶段，更新订单的状态，未支付改为已支付
     *
     */

    void commit(BusinessActionContext businessActionContext);


    /**
     * 事务回滚，删除订单
     *
     */

    void rollback(BusinessActionContext businessActionContext);
}
